﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;

namespace Manas.DynamicDeepZoom.Core
{
    public class LevelTemplateSelector : DataTemplateSelector
    {
        public DataTemplate LevelTemplate { get; set; }

        public DataTemplate ChildrenTemplate { get; set; }

        public int Level { get; set; }

        public int? FromLevel { get; set; }

        public ILevelDefiner LevelDefiner { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (FromLevel.GetValueOrDefault(Level) <= LevelDefiner.Level && LevelDefiner.Level <= this.Level)
            {
                return LevelTemplate;
            }
            else if (LevelDefiner.Level > this.Level)
            {
                return ChildrenTemplate;
            }
            else
            {
                return null;
            }
        }
    }
}
